package ltd.dujiabao.activemq.springboot.config;

import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.command.ActiveMQTopic;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.jms.Destination;
import javax.jms.Topic;


/**
 * @author : DuJiabao
 * @Project : active-mq
 * @Time : 2021/5/6 11:37
 * @Desc :
 */
@Configuration
@EnableJms  // 允许使用JMS
@EnableScheduling  // 允许开启定时任务调度
public class ConfigBean {
  @Value("${myqueue}")
  private String myQueueName;
  @Value("${clocktopic}")
  private String clockTopicName;


  @Bean
  public Destination destination() {
    return new ActiveMQQueue(myQueueName);// 目的地为队列
    //return new ActiveMQTopic(myQueueName);  // 目的地为主题
  }

  @Bean
  public Topic clockTopic() {
    return new ActiveMQTopic(clockTopicName);
  }
}
